local skel = fk.CreateSkill {
  name = "efengqi__qixing",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["efengqi__qixing"] = "七星",
  [":efengqi__qixing"] = "锁定技，游戏开始时，你将手牌摸至7张，并记手牌为“星”。准备阶段，你卜算7，每有一张7置顶，你回复一点体力。",
  ["@@efengqi__star"] = "星",

  ["$efengqi__qixing1"] = "祈星辰之力，佑我蜀汉！",
  ["$efengqi__qixing2"] = "伏望天恩，誓讨汉贼！",
}

skel:addEffect(fk.GameStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local x = 7 - player:getHandcardNum()
    if x > 0 then
      player:drawCards(x, skel.name)
      if player.dead then return end
    end
    for _, id in ipairs(player:getCardIds("h")) do
      room:setCardMark(Fk:getCardById(id), "@@efengqi__star", player.id)
    end
  end,
})

skel:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Start
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local result = room:askToGuanxing(player, { cards = room:getNCards(7), skill_name = skel.name})
    local num = #table.filter(result.top, function (id)
      return Fk:getCardById(id).number == 7
    end)
    if player:isWounded() and player:isAlive() then
      room:recover { num = num, skillName = skel.name, who = player, recoverBy = player }
    end
  end,
})

return skel
